package com.example.test;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

public class MyView extends View
{
	private Paint paint = new Paint();
	private int line_x = 100;
	private int line_y = 100;
	private float count = 0;
	
	public MyView(Context context)
	{
		super(context);
	}
	
	@Override
	protected void onDraw(Canvas canvas)
	{
		super.onDraw(canvas);
		
		if (count > 12)
		{
			count = 0;
		}
		
		int x = (int) (75f * Math.cos(2 * Math.PI * count/12f));
		int y = (int) (75f * Math.sin(2 * Math.PI * count/12f));
		count++;
		
		canvas.drawColor(Color.WHITE);
		paint.setColor(Color.BLACK);
		paint.setStrokeWidth(3);
		canvas.drawLine(line_x, line_y, line_x + x, line_y + y, paint);
		
		paint.setStrokeWidth(2);
		paint.setColor(Color.RED);
		canvas.drawRect(line_x - 5, line_y - 5, line_x + 5, line_y + 5, paint);
		
		paint.setColor(Color.YELLOW);
		canvas.drawRect(line_x - 3, line_y - 3, line_x + 3, line_y + 3, paint);
		
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		
		invalidate();
	}
}
